< previous page page_364 next page >

Page 364
Listing 9.24. continued
    Set ix = td.CreateIndex(strIXMaster)
    ix.Primary = True
    ix.Required = True
    Set fl = ix.CreateField("MasterID")
    ix.Fields.Append fl
    td.Indexes.Append ix
    '
    ' now add defined table
    db.TableDefs.Append td
    '
    ' *now* do the relationship!
    Set rl = db.CreateRelation(strRLName)
    rl.Table = strTDLookUp ' table for lookups
    rl.ForeignTable = strTDMaster ' table to verify
    Set fl = rl.CreateField("UnitID")
    fl.ForeignName = "MasterUnitID"
    rl.Fields.Append fl
    rl.Attributes = dbRelationUpdateCascade
    db.Relations.Append rl
    '
    ' now show relation object
    strMsg = "Relation Properties:" & vbCrLf
    For Each pr In rl.Properties
        strMsg = vbTab & strMsg & pr.Name
        strMsg = strMsg & " = "
        strMsg = strMsg & pr.Value
        strMsg = strMsg & " {"
        strMsg = strMsg & ShowType(pr.Type)
        strMsg = strMsg & "}"
        strMsg = strMsg & vbCrLf
    Next
    '
    strMsg = strMsg & "Relation Fields:" & vbCrLf
    For Each fl In rl.Fields
        strMsg = vbTab & strMsg & fl.Name & vbCrLf
        strMsg = vbTab & strMsg & fl.ForeignName
    Next
    MsgBox strMsg, vbInformation, "Relation"
    '
    ' cleanup
    db.Close
    ws.Close
    '
    Set pr = Nothing
    Set fl = Nothing
    Set ix = Nothing
    Set td = Nothing
    Set db = Nothing
    Set ws = Nothing
    '

 
< previous page page_364 next page >

If you like this book, buy it!